package com.ruoyi.basebill.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.basebill.domain.TWfzRemuneration;
import com.ruoyi.basebill.service.ITWfzRemunerationService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 薪酬总表Controller
 *
 * @author ruoyi
 * @date 2022-12-12
 */
@RestController
@RequestMapping("/basebill/remuneration")
public class TWfzRemunerationController extends BaseController
{
    @Autowired
    private ITWfzRemunerationService tWfzRemunerationService;

    /**
     * 查询薪酬总表列表
     */
    @PreAuthorize("@ss.hasPermi('basebill:remuneration:list')")
    @GetMapping("/list")
    public TableDataInfo list(TWfzRemuneration tWfzRemuneration)
    {
        startPage();
        List<TWfzRemuneration> list = tWfzRemunerationService.selectTWfzRemunerationList(tWfzRemuneration);
        return getDataTable(list);
    }

    /**
     * 导出薪酬总表列表
     */
    @PreAuthorize("@ss.hasPermi('basebill:remuneration:export')")
    @Log(title = "薪酬总表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TWfzRemuneration tWfzRemuneration)
    {
        List<TWfzRemuneration> list = tWfzRemunerationService.selectTWfzRemunerationList(tWfzRemuneration);
        ExcelUtil<TWfzRemuneration> util = new ExcelUtil<TWfzRemuneration>(TWfzRemuneration.class);
        util.exportExcel(response, list, "薪酬总表数据");
    }

    /**
     * 获取薪酬总表详细信息
     */
    @PreAuthorize("@ss.hasPermi('basebill:remuneration:query')")
    @GetMapping(value = "/{fid}")
    public AjaxResult getInfo(@PathVariable("fid") Long fid)
    {
        return success(tWfzRemunerationService.selectTWfzRemunerationByFid(fid));
    }

    /**
     * 新增薪酬总表
     */
    @PreAuthorize("@ss.hasPermi('basebill:remuneration:add')")
    @Log(title = "薪酬总表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TWfzRemuneration tWfzRemuneration)
    {
        //获取当前登录用户的用户名，并且设置到制单人属性中
        tWfzRemuneration.setFcreator(getUsername());
        //获取当前登录用户的用户名，并且设置到修改人属性中
        tWfzRemuneration.setFlastupdateuser(getUsername());
        return toAjax(tWfzRemunerationService.insertTWfzRemuneration(tWfzRemuneration));
    }

    /**
     * 修改薪酬总表
     */
    @PreAuthorize("@ss.hasPermi('basebill:remuneration:edit')")
    @Log(title = "薪酬总表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TWfzRemuneration tWfzRemuneration)
    {
        return toAjax(tWfzRemunerationService.updateTWfzRemuneration(tWfzRemuneration));
    }

    /**
     * 删除薪酬总表
     */
    @PreAuthorize("@ss.hasPermi('basebill:remuneration:remove')")
    @Log(title = "薪酬总表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fids}")
    public AjaxResult remove(@PathVariable Long[] fids)
    {
        return toAjax(tWfzRemunerationService.deleteTWfzRemunerationByFids(fids));
    }

    /**
     * 批量审核薪酬总表
     */
    @PreAuthorize("@ss.hasPermi('basebill:remuneration:remove')")
    @Log(title = "薪酬总表", businessType = BusinessType.UPDATE)
    @PutMapping("/audit/{fids}")
    public AjaxResult audit(@PathVariable Long[] fids)
    {
        return toAjax(tWfzRemunerationService.auditTWfzRemunerationByFids(fids));
    }

    /**
     * 批量反审核薪酬总表
     */
    @PreAuthorize("@ss.hasPermi('basebill:remuneration:remove')")
    @Log(title = "薪酬总表", businessType = BusinessType.UPDATE)
    @PutMapping("/deAudit/{fids}")
    public AjaxResult deAudit(@PathVariable Long[] fids)
    {
        return toAjax(tWfzRemunerationService.deAuditTWfzRemunerationByFids(fids));
    }

    /**
     * 批量废弃薪酬总表
     */
    @PreAuthorize("@ss.hasPermi('basebill:remuneration:remove')")
    @Log(title = "薪酬总表", businessType = BusinessType.UPDATE)
    @PutMapping("/disuse/{fids}")
    public AjaxResult disuse(@PathVariable Long[] fids)
    {
        return toAjax(tWfzRemunerationService.disuseTWfzRemunerationByFids(fids));
    }

    /**
     * 修改薪酬总表单据状态
     */

    @Log(title = "薪酬总-计提工资福利", businessType = BusinessType.UPDATE)
    @PutMapping("/operation/{fids}/{fstate}")
    public AjaxResult operation(@PathVariable Long[] fids,@PathVariable String fstate) {

        return  toAjax(tWfzRemunerationService.operation(fids,fstate));
    }


}
